<template>
  <div class="toast" v-show="isShow">
    {{message}}
  </div>
</template>

<script>
  export default {
    name: "Toast",
    data() {
      return {
        isShow: false,
        message: ""
      }
    },
    methods: {
      success(message="默认值", time=1000) {
        this.message = message
        this.isShow = true
        setTimeout(() => {
          this.isShow = false
        },time)
      }
    }
  }
</script>

<style scoped>
  .toast {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 999;
    height: 30px;
    padding: 0 15px;
    line-height: 30px;
    font-size: 14px;
    text-align: center;
    background-color: rgba(0, 0, 0, .6);
    color: #fff;
    border-radius: 10px;
  }
</style>